#include <QCoreApplication>

#include <cxcamerainfo.h>
#include <CxImageBuffer.hpp>
#include <cxgrabthread.h>
#include <opencv2/opencv.hpp>
#include <signal.h>
#include <stdio.h>
#include <cxshowthread.h>
#include <FbFunction.h>


int                     display_fd;
uchar                   *framebuffer;

void        sig_intFunc(int )
{
    perror("Exit..\n");

    munmap(framebuffer, 640*480*4*2);
    close(display_fd);
    exit(0);
}


int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    char *dev=argv[1];
    signal(SIGINT,sig_intFunc);

    CxCameraInfo            info;
    CxImageBuffer<4>        buffer;

    CxGrabThread
            th(info.newCamera(0,
               DC1394_VIDEO_MODE_640x480_MONO8,DC1394_FRAMERATE_60),
               &buffer);

    th.slot_start();

    display_fd =    initFrameBuffer("/dev/fb1",framebuffer,1024,768);

    CxShowThread    showThread(display_fd,&buffer,framebuffer,NULL);

    showThread.start();

    return a.exec();
}
